Jump to content

What am I doing wrong here? (Urwigo builder)


Delta68

Recommended Posts

Posted
I have a zone called targetzone
I can display its name in a message box OK but if I try and use a function I get an error


The function is just:

 function test()
   return targetzone.Name
end


Thanks
  

image.png.cb92cd0ded13487fb16c503ba24d4f27.png

 

image.png.bf12c082eec4a9456a7bbcd638932c0a.png

 

 

Posted

Do you have named the targetzone? There is a special field for naming zones, variables,... under the description. This name is the name for the luacode

Posted
50 minutes ago, capoaira said:

Do you have named the targetzone? There is a special field for naming zones, variables,... under the description. This name is the name for the luacode

Yes, the zone is named 'targetzone'


image.png.7eae66633dff220dbd66f6ef98cebce8.png

 

 

image.png.df354f2b96402125aea12e0b5caa0f7c.png

 

Posted

oh my explanation was bad, sorry

 

For using zones, variables, ... in lua Code you have to Set the identifier. If this is "automatic" urwigo give the zone a random name...

Posted
1 minute ago, capoaira said:

oh my explanation was bad, sorry

 

For using zones, variables, ... in lua Code you have to Set the identifier. If this is "automatic" urwigo give the zone a random name...


Yay!
Setting 'Identifier" to 'targetzone' as well fixed it!

Thanks
 

Posted
6 hours ago, capoaira said:

urwigo give the zone a random name

 

Wait, so you can't give zones a specific name, like "lobby" or "church"? Doesn't that get confusing? Or am I missing something? Apologies if I'm barking down the wrong river, I saw the post and had flashbacks to my old programming classes and the importance of good variable names for code documentation.

Posted (edited)

The Name is the displayed Name. You can use the spaces or special chars. The identifier is for programming so you cannot use chars like a space.

If you don't give an identifier, URWIGO has to use an random identifier for the source code.

Edited by capoaira
Posted
On 6/23/2021 at 9:17 PM, Unit473L said:

 

Wait, so you can't give zones a specific name, like "lobby" or "church"? Doesn't that get confusing? Or am I missing something? Apologies if I'm barking down the wrong river, I saw the post and had flashbacks to my old programming classes and the importance of good variable names for code documentation.

I suspect it's to make it harder for the code to be read if it is decompiled. :)
 

Posted
On 6/25/2021 at 2:20 AM, Delta68 said:

I suspect it's to make it harder for the code to be read if it is decompiled. :)

I believe that is the case.  A little deterrent is fine.  After all, no one can prevent the easiest method of circumvention: word of mouth sharing of the final location.  So, instead, I advocate for making cartridges an enjoyable, not overlong experience, so people who do skip the cartridge are only depriving themselves of the best part.

Posted

A neater way of doing it is:

 

add a value to your function and use that as your object -

 

function test(val)
   return val.Name
end
 
your lua user expression then should be -
 
test (self)
 
That way you do not need to name the object, and the code is then reusable across all objects.
 
This is K1CKAHA posting on my old family account

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...